﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ServiceModel.Syndication;

namespace RssReaderTemplate.Model.Mappers
{
    public class CompositeMapper : ItemMapper
    {
        public CompositeMapper(PartialMapper titleMapper, PartialMapper contentMapper, PartialMapper authorMapper, PartialMapper publishDateMapper)
            : base()
        {
            TitleMapper = titleMapper;
            ContentMapper = contentMapper;
            AuthorMapper = authorMapper;
            PublishDateMapper = publishDateMapper;
        }

        public PartialMapper TitleMapper { get; set; }
        public PartialMapper ContentMapper { get; set; }
        public PartialMapper AuthorMapper { get; set; }
        public PartialMapper PublishDateMapper { get; set; }

        public override RssItem MapItem(SyndicationItem item)
        {
            var author = AuthorMapper.MapAuthor(item);
            var title = TitleMapper.MapTitle(item);
            var content = ContentMapper.MapContent(item);
            var publishDate = PublishDateMapper.MapPublishDate(item);
            return new RssItem(title, content, author, publishDate);
        }

        public static ItemMapper Instance { get; set; }
    }
}
